# Contributor: Matthias Ahouansou <matthias@ahouansou.cz>
# Maintainer: Matthias Ahouansou <matthias@ahouansou.cz>
pkgname=codeberg-cli
pkgver=0.4.4
pkgrel=0
pkgdesc="CLI Tool for Codeberg similar to gh and glab"
url="https://codeberg.org/RobWalt/codeberg-cli"
arch="all"
license="AGPL-3.0-or-later"
makedepends="
	cargo
	cargo-auditable
	openssl-dev
"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
"
source="$pkgname-$pkgver.tar.gz::https://codeberg.org/RobWalt/codeberg-cli/archive/v$pkgver.tar.gz"
builddir="$srcdir/$pkgname"
options="net !check" # no tests

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

package() {
	install -Dm755 target/release/berg -t "$pkgdir"/usr/bin

	mkdir -p "$pkgdir"/usr/share/bash-completion/completions
	mkdir -p "$pkgdir"/usr/share/fish/vendor_completions.d
	mkdir -p "$pkgdir"/usr/share/zsh/site-functions

	target/release/berg completion bash > "$pkgdir"/usr/share/bash-completion/completions/berg
	target/release/berg completion fish > "$pkgdir"/usr/share/fish/vendor_completions.d/berg.fish
	target/release/berg completion zsh > "$pkgdir"/usr/share/zsh/site-functions/_berg
}

sha512sums="
295b222f581f0346c7dfcac40ab7df341fd428c97a3895029a8fddec1093e5ee9ed5cdc7c72d7c3c3fa0409faa9dd619136f398ff8adbb2165b0465765a83878  codeberg-cli-0.4.4.tar.gz
"
